<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>预取</title>
    <link rel="stylesheet" href="./libs/element-ui/lib/theme-chalk/index.css">
    <style>
        .el-step.is-horizontal.successStyle .el-step__head.is-success {
            color: rgb(38, 50, 170);
            border-color: rgb(38, 50, 170);
        }

        .el-step.is-horizontal.successStyle .el-step__head.is-success .el-step__line {
            background-color: rgb(38, 50, 170);
        }

        /* .el-step.is-horizontal.successStyle .el-step__head.is-success .el-step__line .el-step__line-inner {
            width: 50% !important;
            border-width: 1px !important;
        } */

        .el-step.is-horizontal.successStyle .el-step__main .el-step__title.is-success {
            color: rgb(38, 50, 170);
        }

        .el-step.is-horizontal.successStyle .el-step__main .el-step__description.is-success {
            color: rgb(38, 50, 170);
        }

        .el-step.is-horizontal.currentStyle .el-step__head.is-process {
            color: rgb(1, 117, 1);
            border-color: rgb(1, 117, 1);
        }

        /* .el-step.is-horizontal.currentStyle .el-step__head.is-process .el-step__line {
            background-color: rgb(1, 117, 1);
        } */

        .el-step.is-horizontal.currentStyle .el-step__main .el-step__title.is-process {
            color: rgb(1, 117, 1);
        }

        .el-step.is-horizontal.currentStyle .el-step__main .el-step__description.is-process {
            color: rgb(1, 117, 1);
        }
    </style>
</head>

<body>
    <div id="app" style="padding-top:50px;">
        <el-steps :active="activeIndex" finish-status="success" v-loading="loading">
            <el-step v-for="(item,index) in stepData" :title="item.actName"
                :class="activeIndex == index ? currentStyle : (activeIndex > index ? successStyle : '' )"
                :description=`(${item.assignee})`> </el-step>
        </el-steps>
    </div>
    <script src="./libs/vue.min.js">
    </script>
    <script src="./libs/axios.min.js"></script>
    <script src="./libs/element-ui/lib/index.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    stepData: [],
                    activeIndex: 0,
                    currentStyle: 'currentStyle',
                    successStyle: 'successStyle',
                    loading: false
                }
            },
            created() {
                var processInstanceId = window.location.href.split('=')[1]
                this.getData(processInstanceId)
            },
            methods: {
                getData(processInstanceId) {
                    this.loading = true
                    var origin = window.location.origin,
                        authorization = localStorage.Authorization,
                        self = this
                    axios.post(origin + '/static/task/apis/prefetching/pre/' + processInstanceId, {}, { headers: { authorization: authorization } }).then(function (res) {
                        self.stepData = res.data
                        var statusArr = self.stepData.map(function (item) {
                            return item.status
                        })
                        var activeIndex = statusArr.findIndex(function (val, index, arr) {
                            return val == 'activity'
                        })
                        if (activeIndex == -1) {
                            activeIndex = statusArr.length
                        }
                        self.activeIndex = activeIndex
                        self.loading = false
                    }).catch(function (error) {
                        self.loading = false
                        self.$message({
                            message: error.response.data.message,
                            type: 'error'
                        })
                    })
                }
            }
        })
    </script>
</body>

</html>